package com.jiang.booksystem.controller;

import com.jiang.booksystem.core.ApiResponse;
import com.jiang.booksystem.dao.entity.UserBookBorrow;
import com.jiang.booksystem.dao.entity.dos.UserBookBorrowAggre;
import com.jiang.booksystem.manager.UserBookBorrowManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@RestController
public class UserBookBorrowController {
    @Autowired
    UserBookBorrowManager userBookBorrowManager;

    @GetMapping("/UserBookBorrow/search")
    public ApiResponse<List<UserBookBorrowAggre>> search(@RequestParam(value = "bookName", required = false)  String bookName){
        List<UserBookBorrowAggre> data= userBookBorrowManager.search(bookName);
        return new ApiResponse<>(1, null, data);
    }

    //修改审核
    @GetMapping("/UserBookBorrow/audit")
    public ApiResponse<Void> audit(int id, int status){
        userBookBorrowManager.audit(id,status);
        return new ApiResponse<>(1,"审核成功",null);
    }
}
